const {goodsRouter} = require("./route/good_router")
const {Session} = require('./config/session_config')
const {filter} = require('./filter/global_filter')
const {cartRouter} = require("./route/cart_router")
const cookieParser = require('cookie-parser');
const {userRouter} = require("./route/user_router")
const {couponRouter} = require("./route/coupon_router")
const {orderRouter} = require("./route/order_router")
const {categoryRouter} = require("./route/category_router")
const bodyParser = require('body-parser')
const express = require('express')
const cors = require('cors')
const sessionRouter = require('./route/session');
const emailRouter = require('./route/email_router')

const app = express()
const port = 3000
app.use(filter)
//会话
app.use(Session)
app.use(cookieParser())

app.use(bodyParser.json({limit:'100mb'}))
// app.use(filter)

// 设置信任代理
app.set('trust proxy', true)

// 路由
app.use("/goods",goodsRouter)
app.use("/coupon",couponRouter)
app.use("/category",categoryRouter)
app.use("/cart",cartRouter)
app.use("/user",userRouter)
app.use("/order",orderRouter)
app.use('/session', sessionRouter);
app.use('/email', emailRouter)

app.listen(port,()=>{
  console.log(`服务器正在监听http://127.0.0.1:${port}`);
})

